package com.smooth.site.sx.pc.job.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.smooth.dao.gen.BizCompanyMapper;
import com.smooth.dao.gen.bean.BizCompany;
import com.smooth.dao.gen.bean.BizJob;
import com.smooth.dao.genx.GxJobCategoryMapper;
import com.smooth.dao.genx.bean.JobCatgoryRsp;
import com.smooth.site.sx.pc.job.rsp.MobielIndexJobRsp;
import com.smooth.site.sx.pc.job.rsp.MobileJobCompRsp;

@Component
public class MobileJobService {
	@Autowired
	GxJobCategoryMapper gxJobCategoryMapper;
	@Autowired
	BizCompanyMapper bizCompanyMapper;
	public List<MobielIndexJobRsp> queryBMap(){
		List<MobielIndexJobRsp> mrspList = new ArrayList<MobielIndexJobRsp>();
		List<JobCatgoryRsp> jlist = gxJobCategoryMapper.queryJobsCategorys();
		for(JobCatgoryRsp jobCatgoryRsp : jlist) {
			List<BizJob> blist = gxJobCategoryMapper.queryJobsByCategory(jobCatgoryRsp.getCategoryName());
			List<MobileJobCompRsp> rlist = new ArrayList<MobileJobCompRsp>();
			for(BizJob bizJob : blist) {
				MobileJobCompRsp mobileJobCompRsp = new MobileJobCompRsp();	
				mobileJobCompRsp.setBjob(bizJob);
				PcJobService.convertJobContent(bizJob);
				BizCompany bizCompany = bizCompanyMapper.selectByPrimaryKey(bizJob.getCompId());
				mobileJobCompRsp.setCompLogon(bizCompany.getCompPic());
				
				rlist.add(mobileJobCompRsp);
			}
			MobielIndexJobRsp mobielIndexJobRsp = new MobielIndexJobRsp();
			mobielIndexJobRsp.setBlist(rlist);
			mobielIndexJobRsp.setJobCatgoryRsp(jobCatgoryRsp);
			mrspList.add(mobielIndexJobRsp);
		}
		return mrspList;
	}
}
